<?php
/* Copyright 2006 Sxip Identity */

require_once 'Auth/OpenID/HMACSHA1.php';
require_once 'Auth/OpenID/Association.php';

function whobar_make_signature($params, $secret) {
    // use the OpenID signature algorithm
    // most of the parameters below are just dummy data - we don't need the 
    // full Association functionality, we just need to make a signature.
    // the only important ones are $secret and 'HMAC-SHA1'.
    $assoc = new Auth_OpenID_Association('none', $secret, time(), 3600, 'HMAC-SHA1');
    unset($params['whobar_signature']);
    return base64_encode($assoc->sign($params));
}

function whobar_verify_signature($params, $secret) {
    return (whobar_make_signature($params, $secret) == $params['whobar_signature'] ? true : false);
}

?>
